package com.geek.java.ch04.map;

import java.util.Scanner;
import java.util.HashMap;

public class HashMapTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串");
        String str = sc.nextLine();
        HashMap<Character,Integer> hashMap=new HashMap<>();
        int c=0;
        for (int i=0 ; i < str.length(); i++,c++) {
            int count=0;

            char ch = str.charAt(i);

            for(int j=0; j < str.length(); j++){
                if(ch==str.charAt(j)){
                    count++;
                }
            }
            hashMap.put(ch,count);
        }


        hashMap.keySet().forEach(key->{
            Integer value = hashMap.get(key);
            System.out.println("key = "+key+", value = "+value);
        });


    }
}
